package com.fr.report.script.core.parser;

import com.fr.report.script.Calculator;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FArray;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayExpression extends Atom
{
  private ConditionalOrExpression[] exp_array;

  ArrayExpression(ConditionalOrExpression[] paramArrayOfConditionalOrExpression)
  {
    this.exp_array = paramArrayOfConditionalOrExpression;
  }

  public Object eval(Calculator paramCalculator)
    throws UtilEvalError
  {
    if (this.exp_array == null)
      return Primitive.NULL;
    Object[] arrayOfObject = new Object[this.exp_array.length];
    Arrays.fill(arrayOfObject, Primitive.NULL);
    for (int i = 0; i < this.exp_array.length; ++i)
      if (this.exp_array[i] != null)
        arrayOfObject[i] = this.exp_array[i].eval(paramCalculator);
    return new FArray(arrayOfObject);
  }

  public void traversal4Tiny(TinyHunter paramTinyHunter)
  {
    int i = 0;
    int j = (this.exp_array == null) ? 0 : this.exp_array.length;
    while (i < j)
    {
      if (this.exp_array[i] != null)
        this.exp_array[i].traversal4Tiny(paramTinyHunter);
      ++i;
    }
  }

  public String exString(Calculator paramCalculator)
  {
    Calculator localCalculator = paramCalculator;
    return gen_string(new StringGen(this, localCalculator)
    {
      private final Calculator val$fc;
      private final ArrayExpression this$0;

      public String gen_string()
      {
        return paramConditionalOrExpression.exString(this.val$fc);
      }
    });
  }

  public String toString()
  {
    return gen_string(new StringGen(this)
    {
      private final ArrayExpression this$0;

      public String gen_string()
      {
        return paramConditionalOrExpression.toString();
      }
    });
  }

  private String gen_string(StringGen paramStringGen)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("[");
    int i = 0;
    int j = (this.exp_array == null) ? 0 : this.exp_array.length;
    while (i < j)
    {
      if (i > 0)
        localStringBuffer.append(",");
      localStringBuffer.append(paramStringGen.gen_string(this.exp_array[i]));
      ++i;
    }
    localStringBuffer.append("]");
    return localStringBuffer.toString();
  }

  public String getExpression(int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean)
  {
    int i = paramInt1;
    int j = paramInt2;
    int k = paramInt3;
    int l = paramInt4;
    return gen_string(new StringGen(this, i, j, k, l, paramBoolean)
    {
      private final int val$rowIn;
      private final int val$rowChange;
      private final int val$columnIn;
      private final int val$colChange;
      private final boolean val$isParameter;
      private final ArrayExpression this$0;

      public String gen_string()
      {
        return paramConditionalOrExpression.getExpression(this.val$rowIn, this.val$rowChange, this.val$columnIn, this.val$colChange, this.val$isParameter);
      }
    });
  }

  public String[] parserParameter()
  {
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    int j = this.exp_array.length;
    while (i < j)
    {
      localArrayList.addAll(Arrays.asList(this.exp_array[i].parserParameter()));
      ++i;
    }
    return ((String[])localArrayList.toArray(new String[localArrayList.size()]));
  }

  private static abstract interface StringGen
  {
    public abstract String gen_string(ConditionalOrExpression paramConditionalOrExpression);
  }
}